/**
 * 随机生成一个随机整数[1,3] 输出 剪子/石头/布  1代表:剪子  2代表：石头 3代表:布
 *
 * @author lenovo
 * @version 1.0
 * @date 2023/6/10 13:32
 */

public class test5 {
    /**
     * 电脑类
     *
     * @author kangjx
     * @version 1.0
     * @date 2023/6/10 下午2:42
     */


        String player;

        public void setPlayer(String player) {
            this.player = player;
        }

        public String getPlayer() {
            return this.player;
        }

        /**
         * 随机生成1 -3数
         *
         * @return
         */
        public int createNum() {
            //(int)(Math.random()* (最大値-小値+1))+ 最小
            return (int) (Math.random() * 3) + 1;
        }

        /**
         * 文本提示了
         *
         * @param i
         * @return
         */
        public String getMessWithNum(int i) {
            switch (i) {
                case 1:
                    return "剪子";
                case 2:
                    return "石头";
                case 3:
                    return "布";
                default:
                    return "错了";
            }
        }

        public void winner(test5 c) {
            int otherComputerInt = c.createNum();
            int myselfInt = this.createNum();

            String otherComMess = c.getMessWithNum(otherComputerInt);
            String myselfMess = c.getMessWithNum(myselfInt);

            if (myselfInt == 1 && otherComputerInt == 3) {
                System.out.printf("玩家%s出了一个%s,玩家%s出一个%s,恭喜玩家%s胜出\n", c.getPlayer(), otherComMess, this.getPlayer(), myselfMess, this.getPlayer());
            } else if (myselfInt == 3 && otherComputerInt == 1) {
                System.out.printf("玩家%s出了一个%s,玩家%s出一个%s,恭喜玩家%s胜出\n", c.getPlayer(), otherComMess, this.getPlayer(), myselfMess, c.getPlayer());
            } else if (otherComputerInt > myselfInt) {
                System.out.printf("玩家%s出了一个%s,玩家%s出一个%s,恭喜玩家%s胜出\n", c.getPlayer(), otherComMess, this.getPlayer(), myselfMess, c.getPlayer());
            }  else if (myselfInt > otherComputerInt) {
                System.out.printf("玩家%s出了一个%s,玩家%s出一个%s,恭喜玩家%s胜出\n", c.getPlayer(), otherComMess, this.getPlayer(), myselfMess, this.getPlayer());
            } else {
                System.out.printf("玩家%s出了一个%s,玩家%s出一个%s,平局\n", c.getPlayer(), otherComMess, this.getPlayer(), myselfMess);
            }

        }

    }



